﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using QuanLyKho.BL;
using QuanLyKho.Entity;
namespace QuanLyKho.GUI
{
    public partial class uNhapHangHoa : DevExpress.XtraEditors.XtraUserControl
    {
        public uNhapHangHoa()
        {
            InitializeComponent();
        }

        private void uNhapHangHoa_Load(object sender, EventArgs e)
        {
            bNhomHang bnh = new bNhomHang();
            DataTable dt=bnh.getAllNhomHang();
            cbNhomHang.Properties.DataSource = dt;
          //  cbNhomHang.DataBindings.Add("EditValue", dt, "nhId");
        }

        private void btLuu_Click(object sender, EventArgs e)
        {
            DataRowView dv=(DataRowView)cbNhomHang.EditValue;
            eHangHoa hh = new eHangHoa();
            hh.nhId = int.Parse(dv.Row[0].ToString());
            hh.maHang = txtMahang.Text;
            hh.ngayNhap = DateTime.Now;
            hh.soLuong = int.Parse(txtSoLuong.Text);
            hh.tenHang = txtTenHang.Text;
            hh.donViTinh = txtDonViTinh.Text;
            hh.donGia = float.Parse(txtDonGia.Text);
            bHangHoa bh = new bHangHoa();

            bh.insertHangHoa(hh);
            MessageBox.Show("Đã thêm hàng hóa thành công !");
            this.Hide();
        }
    }
}
